﻿<%@ Page Title="Продукти" Language="C#" MasterPageFile="~/LeftColumn.master" AutoEventWireup="true" CodeBehind="Products.aspx.cs" Inherits="Supermarket.Web.CashierPages.Products" %>
<asp:Content ID="Content1" ContentPlaceHolderID="RightContent" runat="server">
   
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:GridView ID="GridViewProducts" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px"
                CellPadding="3" CellSpacing="2" DataSourceID="odsProducts" PageSize="15" 
                DataKeyNames="ProductId">
                <Columns>
                    <asp:CommandField CancelText="Отказ" EditText="Промени" ShowEditButton="True" UpdateText="Обнови" />
                    <asp:BoundField DataField="ProductName" HeaderText="Продукт" SortExpression="ProductName" />
                    <asp:BoundField DataField="ProductPrice" HeaderText="Цена" SortExpression="ProductPrice" DataFormatString="{0:0.00}" />
                    <asp:BoundField DataField="MeasureCode" HeaderText="Код" ReadOnly="True" SortExpression="MeasureCode" />
                    <asp:BoundField DataField="CompanyName" HeaderText="Производител" ReadOnly="True"
                        SortExpression="CompanyName" />
                    <asp:BoundField DataField="CategoryName" HeaderText="Категория" ReadOnly="True" SortExpression="CategoryName" />
                    <asp:BoundField DataField="InStock" HeaderText="Наличност" ReadOnly="True" SortExpression="InStock" />
                </Columns>
                <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
                <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
                <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
                <RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
                <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
                <SortedAscendingCellStyle BackColor="#FFF1D4" />
                <SortedAscendingHeaderStyle BackColor="#B95C30" />
                <SortedDescendingCellStyle BackColor="#F1E5CE" />
                <SortedDescendingHeaderStyle BackColor="#93451F" />
            </asp:GridView>   
           </ContentTemplate>     
   </asp:UpdatePanel>
    <br />
            <asp:UpdatePanel ID="UpdatePanel2" runat="server">
            <ContentTemplate>
            <asp:LinkButton ID="LinkButtonAdd" runat="server" OnClick="LinkButtonAdd_Click" Text="Добави продукт" />
    <asp:Panel ID="PanelAddProduct" runat="server" Visible="false">
        <asp:FormView ID="fvProduct" runat="server" DefaultMode="Insert"
            OnItemInserting="fvProduct_ItemInserting">
            <InsertItemTemplate>
                <table class="text-align:center">
                    <tr>
                        <td>
                            Продукт:
                        </td>
                        <td>
                            <asp:TextBox ID="TextBoxProductName" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Цена:
                        </td>
                        <td>
                            <asp:TextBox ID="TextBoxProductPrice" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Производител:
                        </td>
                        <td>
                            <asp:DropDownList ID="ddlCompanyName" runat="server" DataSourceID="odsCompanies"
                                DataTextField="CompanyName" DataValueField="CompanyId">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Категория:
                        </td>
                        <td>
                            <asp:DropDownList ID="ddlCategoryName" runat="server" DataSourceID="odsCategories"
                                DataTextField="CategoryName" DataValueField="CategoryId">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Mер. ед.:
                        </td>
                        <td>
                            <asp:DropDownList ID="ddlMeasureCode" runat="server" DataSourceID="odsMeasures" DataTextField="MeasureName"
                                DataValueField="MeasureId">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr style="text-align: center">
                        <td>
                            <asp:Button ID="ButtonAdd" runat="server" Text="Добави" CommandName="Insert" />
                        </td>
                        <td>
                            <asp:Button ID="ButtonCancel" runat="server" Text="Отказ" OnClick="ButtonCancel_Click" />
                        </td>
                    </tr>
                </table>
            </InsertItemTemplate>
        </asp:FormView>

    </asp:Panel>
    </ContentTemplate>
    </asp:UpdatePanel>
        
    <asp:ObjectDataSource ID="odsProducts" runat="server"
        SelectMethod="GetAllProducts" TypeName="Supermarket.Bll.ProductManager" 
        UpdateMethod="Update">
        <UpdateParameters>
            <asp:Parameter Name="id" Type="Int32" />
            <asp:Parameter Name="productName" Type="String" />
            <asp:Parameter Name="productPrice" Type="Decimal" />
            <asp:Parameter Name="companyId" Type="Int32" />
            <asp:Parameter Name="categoryId" Type="Int32" />
            <asp:Parameter Name="measureId" Type="Int32" />
        </UpdateParameters>
    </asp:ObjectDataSource>
    <asp:ObjectDataSource ID="odsCompanies" runat="server" SelectMethod="GetAllCompanies"
        TypeName="Supermarket.Bll.CompanyManager"></asp:ObjectDataSource>
    <asp:ObjectDataSource ID="odsCategories" runat="server" SelectMethod="GetAllCategories"
        TypeName="Supermarket.Bll.CategoryManager"></asp:ObjectDataSource>
    <asp:ObjectDataSource ID="odsMeasures" runat="server" SelectMethod="GetAllMeasures"
        TypeName="Supermarket.Bll.MeasureManager"></asp:ObjectDataSource>   
</asp:Content>
